# -*- encoding=utf8 -*-
        
__author__ = "Bryan.Chen"
__desc__=""
        
from airtest.core.api import *
        
auto_setup(__file__)
        
from poco.drivers.std import StdPoco
poco = StdPoco()
        
using("../FlowTest.air")
import FlowTest
        
class Club_CloseClub(FlowTest.BaseTestCase):
    def __init__(self):
        print("%s __init__" % (__file__))
        
    def runTest(self, args):
        print("%s runTest" % (__file__))

        clubHomePageLayer = poco("ClubHomePageLayer")

        if not clubHomePageLayer.exists():
            return False

        myCreateList = clubHomePageLayer.offspring("my_create_list")
        clubItems = myCreateList.offspring("my_create_item")
        for i in range(0, len(clubItems)):
            txtName = clubItems[i].offspring("club_name").get_text()
            if txtName.startswith("AT_"):
                self.clickButton(clubItems[i])
                break

        clubPageLayer = poco("ClubPageLayer")
        btnInfoNormal = clubPageLayer.offspring("info_normal")
        btnInfoSelect = clubPageLayer.offspring("info_select")

        # 切换到俱乐部管理面板
        if not btnInfoSelect.exists():
            self.clickButton(btnInfoNormal)
        
        btnClose = clubPageLayer.offspring("red_btn")
        self.clickButton(btnClose)

        tipsDialog = clubPageLayer.offspring("LBTipsLayer")
        btnConfirm = tipsDialog.offspring("ok_btn_2")
        self.clickButton(btnConfirm)

        # 获取提示信息，并进行比对
        toastView = poco("ToastView")
        if toastView.exists():
            txtContent = toastView.offspring("text_content").get_text()
            assert_equal(txtContent, "关停俱乐部成功", "关停俱乐部成功")
        
        return True
        
_instance = Club_CloseClub()
runTest = _instance.runTest
